package com.nttuan.model.entity;

import android.nfc.Tag;
import android.util.Log;

import org.json.JSONObject;

/**
 * Created by NT Tuan on 10/20/2014.
 */
public class User {
    private static final String TAG ="user entity";
    public static final String TABLE_NAME = "user";

    public static final String USER_ID = "userId";
    public static final String USER_NAME = "userName";
    public static final String EMAIL = "email";
    public static final String PASSWORD = "password";
    public static final String ADDRESS = "address";
    public static final String PHONE = "phone";
    public static final String FACEBOOK = "facebook";
    public static final String SKYPE = "skype";
    public static final String IS_ACTIVE = "isActive";

    private int userId;
    private String userName;
    private String email;
    private String password;
    private String address;
    private String phone;
    private String facebook;
    private String skype;
    private boolean isActive;

    public User(){}
    public User(int userId, String userName, String email, String password, String address, String phone, String facebook, String skype, boolean isActive) {
        this.userId = userId;
        this.userName = userName;
        this.email = email;
        this.password = password;
        this.address = address;
        this.phone = phone;
        this.facebook = facebook;
        this.skype = skype;
        this.isActive = isActive;
    }

    public User(int userId) {
        this.userId = userId;
    }

    public int getUserId() {
        return userId;
    }

    public void setUserId(int userId) {
        this.userId = userId;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getFacebook() {
        return facebook;
    }

    public void setFacebook(String facebook) {
        this.facebook = facebook;
    }

    public String getSkype() {
        return skype;
    }

    public void setSkype(String skype) {
        this.skype = skype;
    }

    public boolean isActive() {
        return isActive;
    }

    public void setActive(boolean isActive) {
        this.isActive = isActive;
    }

    public static JSONObject jUser(User user, boolean isLeader){
        try{
            JSONObject object = new JSONObject();
            object.put(USER_NAME, user.getUserName());
            if(isLeader){
                object.put(EMAIL, user.getEmail());
                object.put(ADDRESS, user.getAddress());
                object.put(PHONE, user.getPhone());
                object.put(FACEBOOK, user.getFacebook());
                object.put(SKYPE, user.getSkype());
            }
            JSONObject result = new JSONObject();
            result.put(TABLE_NAME, object);
            return result;
        }catch (Exception e){
            Log.d(TAG,"jUser:"+ e.toString());
        }
        return null;
    }
}
